package org.iabako.client.ui.page.business.sale;

import org.iabako.client.config.page.PageConfigEnum;
import org.iabako.client.navigation.NavigationController;
import org.iabako.client.tools.IabakoAsyncCallback;
import org.iabako.client.ui.form.business.sale.make.SaleMakeForm;
import org.iabako.shared.entity.business.AbstractEntity;
import org.iabako.shared.entity.business.Sale;

/**
 * Created by jose on 12/07/15.
 */
public class QuoteModify extends SaleMakeForm {

    public QuoteModify() {
        super(PageConfigEnum.QuoteModify, "");

        contentPanel.setVisible(false);
        waitIconPanel.setVisible(true);

        activateQuoteMode();
        //By default consultation mode (if modification mode, it will be change by restoreDraft => initialize)
        saleMakeConfirmation.enableModificationMode(false);

        final String[] params = NavigationController.getInstance().getParams();

        saleServiceAsync.getById(Long.parseLong(params[0]), new IabakoAsyncCallback<AbstractEntity>() {
            public void onSuccess(AbstractEntity result) {
                restoreDraft((Sale) result);
                super.onSuccess(result);
            }
        });
    }
}
